//
//  LNHGoodsDetailTitleView.m
//  LNH
//
//  Created by cruise on 2018/2/7.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "LNHGoodsDetailTitleView.h"

@interface LNHGoodsDetailTitleView()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIView *leftLineView;
@property (nonatomic, strong) UIView *rightLineView;

@end

@implementation LNHGoodsDetailTitleView


/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
    
    
}

/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    
    
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    
    [self setBackgroundColor:[UIColor whiteColor]];
    
    [self addSubview:self.titleLabel];
    [self addSubview:self.leftLineView];
    [self addSubview:self.rightLineView];
    
    [self setNeedsUpdateConstraints];
}

-(void) updateConstraints {
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.width.mas_equalTo(50);
        make.centerX.equalTo(self);
    }];
    
    [self.leftLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self);
        make.right.equalTo(self.titleLabel.mas_left);
        make.height.mas_equalTo(ONE_PIXEL);
    }];
    
    [self.rightLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self.titleLabel.mas_right);
        make.right.equalTo(self.mas_right);
        make.height.mas_equalTo(ONE_PIXEL);
    }];
    
    [super updateConstraints];
    
}

#pragma mark - Getter

-(UILabel *) titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        [_titleLabel setText:@"详情"];
        [_titleLabel setTextAlignment:NSTextAlignmentCenter];
        [_titleLabel setTextColor:RGBCOLOR(158, 158, 158)];
        [_titleLabel setFont:[UIFont systemFontOfSize:14]];
    }
    return _titleLabel;
}

-(UIView *) leftLineView {
    if (!_leftLineView) {
        _leftLineView = [UIView new];
        [_leftLineView setBackgroundColor:RGBCOLOR(217, 217, 217)];
    }
    return _leftLineView;
}

-(UIView *) rightLineView {
    if (!_rightLineView) {
        _rightLineView = [UIView new];
        [_rightLineView setBackgroundColor:RGBCOLOR(217, 217, 217)];
    }
    return _rightLineView;
}

@end
